package com.net.shop.car.manager.api.volley.response;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.net.shop.car.manager.api.model.ChongZhi;
import com.net.shop.car.manager.api.volley.Response;
import com.net.shop.car.manager.utils.Constants;
import com.net.shop.car.manager.utils.LogUtils;
import com.net.shop.car.manager.utils.StringUtils;

public class VbListGuizeResponse extends Response {
	private String mvb;
	private ArrayList<ChongZhi> exchangeRuleArray;

	public VbListGuizeResponse() {
		super(Constants.GETVB);
		// TODO Auto-generated constructor stub
	}

	@Override
	public String[] getContentTags() {
		String[] result = new String[] { "mvb", "exchange_rule_array" };
		return result;
	}

	@Override
	public void parseContent(String content, int index) {
		if (0 == index) {
			parseHotCity(content);
		} else if (1 == index) {
			mvb = StringUtils.filterNull(content);
		}
	}

	/**
	 * @param content
	 *            String
	 */
	private void parseHotCity(String content) {
		try {
			JSONArray jsonArray = new JSONArray(content);
			int len = jsonArray.length();
			for (int i = 0; i < len; i++) {
				JSONObject jsonObject = jsonArray.getJSONObject(i);
				exchangeRuleArray.add(new ChongZhi(false, jsonObject.getString("RMB")));
			}
		} catch (JSONException e) {
			LogUtils.e(e.getMessage());
		}
	}

	public String getMvb() {
		return mvb;
	}

	public ArrayList<ChongZhi> getExchangeRuleArray() {
		return exchangeRuleArray;
	}

}
